package com.neusoft.javafeatures9.nio;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.*;
import java.nio.channels.ByteChannel;
import java.nio.channels.Channel;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class NioDemo {
    public static void main(String[] args) throws IOException {
        Channels.newChannel(new FileInputStream("src/main/java/com/neusoft/javafeatures9/nio/NioDemo.java"));
        LongBuffer longBuffer = LongBuffer.allocate(10);

        Files.readAllBytes(Paths.get("src/main/java/com/neusoft/javafeatures9/nio/NioDemo.java"));
        FileChannel fileChannel = new FileInputStream("src/main/java/com/neusoft/javafeatures9/nio/NioDemo.java").getChannel();

        Charset charset = Charset.forName("UTF-8");
        Charset.availableCharsets();
        charset.decode(ByteBuffer.wrap(new byte[]{0x61, 0x62, 0x63}));
        charset.encode(CharBuffer.wrap("abc"));
        File file = new File("src/main/java/com/neusoft/javafeatures9/nio/NioDemo.java");

        Path path = Paths.get("src/main/java/com/neusoft/javafeatures9/nio/NioDemo.java");
        Files.exists(path);
    }
}
